<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Imageene
{
	
	var $available_languages = array(
				"en" 	=> "english",
				"en_us" => "english",
				"es" 	=> "spanish",
				"es_es" => "spanish",
				"fr" 	=> "french",
				"fr_fr" => "french"
	);

	function is_language_available($l) {
		if(key_exists($l, $this->available_languages)) {
			return $this->available_languages[$l];
		}
		else {
			return FALSE;
		}
	}
	
	function __construct()
	{
		$this->ci =& get_instance();
		$this->ci->load->config('imageene', TRUE);
	}

	function page($view, $data = NULL) {
		$this->_template("pages/$view", $data);
	}
	
	function admin($view, $data = NULL) {
		$this->_template("admin/$view", $data);
	}
	
	function user($view, $data = NULL) {
		$data['uilang'] = $this->ci->session->userdata('uilang');
		$data['user_menu'] = $this->ci->load->view('users/common/user_menu', 	NULL, 	TRUE);
		
		$content['common_pre'] 		= $this->ci->load->view('common/pre', 		NULL, 	TRUE);
		$content['common_header']	= $this->ci->load->view('common/header',	NULL, 	TRUE);
		$content['common_content']	= $this->ci->load->view("users/$view", 		$data,	TRUE);
		$content['common_footer']	= $this->ci->load->view('common/footer', 	NULL,	TRUE);
		$content['common_forms']	= $this->ci->load->view('common/forms', 	NULL,	TRUE);
		$content['common_post']		= $this->ci->load->view('common/post',		NULL,	TRUE);
		
		$this->ci->load->view('common/container', $content);
		
	}
	
	function _template($view, $data)
	{
		$data['uilang'] = $this->ci->session->userdata('uilang');
				
		$content['common_pre'] 		= $this->ci->load->view('common/pre', 		NULL, 	TRUE);
		$content['common_header']	= $this->ci->load->view('common/header',	NULL, 	TRUE);
		$content['common_content']	= $this->ci->load->view($view, 				$data,	TRUE);
		$content['common_footer']	= $this->ci->load->view('common/footer', 	NULL,	TRUE);
		$content['common_forms']	= $this->ci->load->view('common/forms', 	NULL,	TRUE);
		$content['common_post']		= $this->ci->load->view('common/post',		NULL,	TRUE);
		
		$this->ci->load->view('common/container', $content);
	}
	
	function get_avatars()
	{
		$this->ci->load->model('avatar');
		return $this->ci->avatar->get_available_avatars($this->ci->config->config['avatar_path']);
	}
	
	function get_avatar_path($img)
	{
		return ($img) ? ($this->ci->config->config['avatar_path'] . "/" . $img) : NULL;
	}
	
	function get_dictionary_by_reftype_value($reftype=NULL, $value=NULL)
	{
		$this->ci->load->model('dictionary');
		return $this->ci->dictionary->get_entry_by_reftype_value($reftype, $value);
	}
	
	function get_config($item) {
		return isset($this->ci->config->config[$item]) ? $this->ci->config->config[$item] : NULL;
	}
	
	function include_user_header($include_menu) {
		include_once('header.php');
	}
}

/* End of file imageene.php */
/* Location: ./application/libraries/imageene.php */